const pool = require("../connection/sqlPool");


async function GETPUBLISH() {
    try {
        const promisePool = pool.promise();
      const [rows,fileds] = await promisePool.query('SELECT * FROM My_publish');


      return rows

    } catch(err){
        return err.message
    }


  }
  async function GETRECIPE() {
    try {
        const promisePool = pool.promise();
      const [rows,fileds] = await promisePool.query('SELECT * FROM Ricipe');


      return rows

    } catch(err){
        return err.message
    }


  }
  async function GETUSER() {
    try {
        const promisePool = pool.promise();
      const [rows,fileds] = await promisePool.query('SELECT * FROM User');


      return rows

    } catch(err){
        return err.message
    }


  }
  async function HOUDEBARK(username,password){
    const promisePool = pool.promise();
    try{
        const [rows,fileds] = await promisePool.query('SELECT * FROM `Glygl` WHERE `username`=? AND `password`=?',[username,password]);
        if(rows.length){
            return {msg:'登录成功',username:rows[0].username}
        }else{
            return {msg:rows}
        }
    }catch(error){
        return {msg:'未进行登录',Error:error.message}
    }
}
async function GETHOUUSER(){
    const promisePool = pool.promise();
    try{
        const [rows,fileds] = await promisePool.query('SELECT * FROM Glygl');
        return rows
    }
    catch(error){
        return error.message
    }
    }
module.exports = {GETPUBLISH,GETRECIPE,GETUSER,HOUDEBARK,GETHOUUSER};